<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateFamilyMembersTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('family_members', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('family_id')->comment('家系ID');
            $table->string('title')->comment('姓名');
            $table->string('title_amend')->comment('姓名修正');
            $table->string('code')->unique()->comment('编号');
            $table->unsignedTinyInteger('gender')->default(1)->comment('性别，0:女,1:男,2:未知');
            $table->dateTime('birthday')->nullable()->comment('出生日期');
            $table->string('age')->nullable()->comment('年龄');
            $table->string('age_unit')->nullable()->comment('年龄单位');
            $table->string('age_range')->nullable()->comment('年龄区段');
            $table->string('age_range_unit')->nullable()->comment('年龄区段单位');
            $table->string('relation')->comment('家系关系(从字典选择)');
            $table->string('birthplace')->nullable()->comment('籍贯');
            $table->string('address')->nullable()->comment('家庭地址');
            $table->string('wechat')->nullable()->comment('微信号');
            $table->string('contact')->nullable()->comment('联系人');
            $table->string('contact_phone')->nullable()->comment('联系人电话');
            $table->string('nation')->nullable()->comment('民族');
            $table->string('is_patient')->comment('是否患病(从字典选择)');
            $table->text('clinical_diagnosis')->nullable()->comment('临床诊断');
            $table->string('case_code')->nullable()->comment('病案号');
            $table->text('family_history')->nullable()->comment('家族史');
            $table->string('clinical_keyword')->nullable()->comment('临床关键词');
            $table->dateTime('first_date')->nullable()->comment('首次发病日期');
            $table->string('identity_card')->nullable()->comment('身份证');
            $table->unsignedInteger('customer')->nullable()->comment('所属客户');
            $table->unsignedInteger('department')->nullable()->comment('所属科室');
            $table->unsignedInteger('doctor')->nullable()->comment('所属医生');
            $table->unsignedInteger('created_by')->comment('创建者');
            $table->unsignedInteger('updated_by')->comment('更新者');
            $table->string('data_scope')->nullable()->comment('数据域');
            $table->timestamps();

            $table->comment = '家系成员表';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('family_members');
    }

}
